<template>
  <div class="user">
    <!-- 厨房电器 -->
    <div class="electricalUser">
      <ul>
        <li v-for="item in userData.category" :key="item.cat_id">
          <img :src="item.touch_icon" alt="" />
          <span>
            {{ item.cat_name }}
          </span>
        </li>
      </ul>
    </div>

    <!-- 品牌精选 -->
    <div class="brandTotal">
      <p>品牌精选</p>
      <ul class="choosebrand">
        <li v-for="item in userData.brand" :key="item.brand_id">
          <img :src="item.brand_logo" alt="" />
          <span>{{ item.brand_name }}</span>
        </li>
      </ul>
    </div>

<!-- 第三个模块 -->
 <ul class="detail-total">
          <li v-for="item in resData" :key="item.cat_id">
            <img :src="item.original_img" alt="" />
            <span class="detail-span">{{ item.name }}</span>
            <span class="detail-spantwo">{{ item.shop_price_formated }}</span>
            <div class="stores">进店</div>
            <span style="color: grey; font-size: 14px"
              >{{ item.sales_volume }}人已购买</span
            >
          </li>
        </ul>
    
  </div>
</template>
<script>
export default {
  data() {
    return {
      resData: "",
      userData:"",
      list:[]
    };
  },
  mounted() {
    this.getfoods(),
    this.getstore()
  },
  computed: {

  },
  methods: {
    getfoods() {
      this.$store
        .dispatch({
          type: "detailclassify",
          cat_id: 858,
        })
        .then((data) => {
          this.resData = data;
        });
    },

     getstore() {
      this.$store
        .dispatch({
          type: "userelectrical",
          cat_id: 858,
        })
        .then((data) => {
          this.userData= data;
        });
    },
  },
};
</script>

<style scoped lang="less">
* {
  margin: 0;
  padding: 0;
}
.user {
  background-color: #f4f4f4;
  padding: 0px 10px;
  //   厨房电器
  .electricalUser {
    width: 100%;
    height: 120px;
    background-color: #fff;
    border-radius: 15px;
    margin-bottom: 15px;

    ul {
      width: 100%;
      height: 100%;
      display: flex;
      justify-content: space-around;
      align-items: center;
      li {
        width: 20%;
        height: 30%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        img {
          width: 54px;
          height: 54px;
          margin-bottom: 10px;
        }
      }
    }
  }

  //   品牌精选
  .brandTotal {
    width: 100%;
    height: 300px;
    background-color: #fff;
    border-radius: 15px;
    overflow: hidden;

    p {
      margin-top: 10px;
      margin-left: 22px;
      font-size: 16px;
    }
    .choosebrand {
      width: 100%;
      height: 80%;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-around;
      li {
        width: 24%;
        height: 33%;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        img {
          width: 71px;
          height: 32px;
          margin-bottom: 10px;
        }
      }
    }
  }


//   第三个模块
  .detail-total {
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    background-color: #f4f4f4;
    li {
      width: 45%;
      height: 30%;
      display: flex;
      flex-direction: column;
      //   align-items: center;
      justify-content: space-between;
      padding: 5px;
      text-align: left;
      margin-right: 3px;
      margin-left: 3px;
      //   border: 1px solid red;
      background-color: #fff;
      margin-top: 5px;
      img {
        width: 90%;
        height: 82%;
        margin-bottom: 5px;
      }
      .detail-span {
        font-size: 14px;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-line-clamp: 2;
        margin-bottom: 5px;
        margin-top: 5px;
      }
      .detail-spantwo {
        color: red;
        font-size: 14px;
        margin-bottom: 5px;
        margin-top: 5px;
      }
      .stores {
        width: 40px;
        height: 20px;
        background-color: red;
        color: #fff;
        font-size: 12px;
        text-align: center;
        margin-bottom: 5px;
        margin-top: 5px;
      }
    }
  }
}
</style>